//
//  studyTeachCell.m
//  doubleEduStudents
//
//  Created by 盛洋 on 2021/4/7.
//  Copyright © 2021 shengYang. All rights reserved.
//

#import "studyTeachCell.h"

@implementation studyTeachCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.name_lab.font = AutoLabFont2;
    self.people_lab.font = self.eyes_lab.font =  self.pingji_lab.font = self.downLoad_btn.titleLabel.font = self.ziliao_btn.titleLabel.font = self.age_lab.font = self.easy_lab.font = self.lines_lab.font = self.time_lab.font = AutoLabFont3;
    [self.downLoad_btn addTarget:self action:@selector(upLoadZuoPin) forControlEvents:UIControlEventTouchUpInside];
    [self.ziliao_btn addTarget:self action:@selector(showCanKaoZiLiao) forControlEvents:UIControlEventTouchUpInside];

}

-(void)setTeachDic:(NSDictionary *)teachDic{
    _teachDic = teachDic;
    [_left_img sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_teachDic[@"courseIcon"]]] placeholderImage:DefaultImg];
    _people_lab.text = [NSString stringWithFormat:@"%@",_teachDic[@"courseLook"]];
    
    //课程付费类型：0免费，1付费
    if ([_teachDic[@"coursePayType"] intValue] == 1) {
        _free_lab.text = [NSString stringWithFormat:@"付费"];
        _free_lab.backgroundColor = [UIColor redColor];

    }else{
        _free_lab.text = [NSString stringWithFormat:@"免费"];
        _free_lab.backgroundColor = [UIColor colorWithHexString:@"#34A444"];
    }
    APPViewBorderRadius(self.free_lab, self.free_lab.frame.size.height/3, .1, [UIColor clearColor]);
     APPViewBorderRadius(self.left_img, 10, .1, [UIColor clearColor]);
    _name_lab.text = [NSString stringWithFormat:@"%@",_teachDic[@"courseName"]];
    _age_lab.text = [NSString stringWithFormat:@"适合年龄：%@",_teachDic[@"courseAge"]];
    _eyes_lab.text = [NSString stringWithFormat:@"课程级别：%@",_teachDic[@"levelName"]];
    _lines_lab.text = [NSString stringWithFormat:@"场  景：%@",_teachDic[@"courseScene"]];
    _time_lab.text = [NSString stringWithFormat:@"时  长：%@小时",_teachDic[@"courseTime"]];
    //星星展示
    if ([_teachDic[@"courseDifficulty"] intValue] == 0) {
        self.star1.hidden = self.star2.hidden = self.star3.hidden = self.star4.hidden = self.pingji_lab.hidden = YES;
    }else if ([_teachDic[@"courseDifficulty"] intValue] == 1){
        self.star1.hidden = NO;
        self.star2.hidden = self.star3.hidden = self.star4.hidden = YES;
    }else if ([_teachDic[@"courseDifficulty"] intValue] == 2){
        self.star1.hidden = self.star2.hidden = NO;
        self.star3.hidden = self.star4.hidden = YES;
    }else if ([_teachDic[@"courseDifficulty"] intValue] == 3){
        self.star1.hidden = self.star2.hidden = self.star3.hidden = NO;
        self.star4.hidden = YES;
    }else if ([_teachDic[@"courseDifficulty"] intValue] == 4){
        self.star1.hidden = self.star2.hidden = self.star3.hidden = self.star4.hidden = NO;
    }
    
}

-(void)upLoadZuoPin{
    if ([self.delegate respondsToSelector:@selector(upLoadZuoPin)]) {
        [self.delegate upLoadZuoPin];
    }
}

-(void)showCanKaoZiLiao{
    if ([self.delegate respondsToSelector:@selector(showCanKaoZiLiao)]) {
        [self.delegate showCanKaoZiLiao];
    }
}

@end
